import { RouteRecordRaw } from 'vue-router'
import Layout from '@/layout/index.vue'

export const staticRoutes: Array<RouteRecordRaw> = [
    {
        path: '/demo',
        component: Layout,
        meta: {
            title: 'demo',
        },
        children: [
            {
                path: 'home',
                name: 'home',
                component: () => import('@/views/home.vue'),
                meta: {
                    title: 'home',
                },
            },
            {
                path: 'about',
                name: 'about',
                component: () => import('@/views/about.vue'),
                meta: {
                    title: 'about',
                },
            },
        ],
    },
]
const modules = import.meta.glob('@/views/demo/*/index.vue')

const demoChild = Object.keys(modules).map((path) => {
    const name = path.split('/')[3]
    return {
        path: name,
        name,
        component: modules[path],
        meta: {
            title: name,
        },
    }
})
staticRoutes[0].children.push(...demoChild)

const noMenuModules = import.meta.glob('@/views/noMenu/*/index.vue')

const noMenuChild = Object.keys(noMenuModules).map((path) => {
    const name = path.split('/')[3]
    return {
        path: `/${name}`,
        name,
        component: noMenuModules[path],
        meta: {
            title: name,
        },
    }
})
staticRoutes.push(...noMenuChild)

console.log(staticRoutes)
